<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
<base href="<%=basePath%>">
<%@include file="/esayuiStyle.jsp" %>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
	<link rel="stylesheet" type="text/css" href="css/tabs/htmleaf-demo.css">
   	<link rel="stylesheet" type="text/css" href="css/tabs/normalize.css"> 	 
	<link rel="stylesheet" type="text/css" href="css/tabs/style.css">
</head>
<body>
<div class="tab-group">
    <section id="tab1" title="未登记病人">
		<div id="weidengTb">
			<label class="textbox-label textbox-label-left" for="_easyui_textbox_input2" style="text-align: left;width:130px; height: 26px; line-height: 26px;">姓名/标识/身份证:</label>
		 	<input class="easyui-textbox" id="weidengPatientName" name="patient.name"  style="width:150px;">
			<label class="textbox-label textbox-label-left" for="_easyui_textbox_input2" style="text-align: left;width:60px; height: 26px; line-height: 26px;">挂号类型:</label>
		    <input id="weidengTodayRegistrationRankClassType" class="easyui-combobox" name="" style="width:150px;" data-options=" 
			      url:'registrationChargeType/selectAll', 
			      method:'get', 
			      valueField:'id', 
			      textField:'typeName', 
			      panelheight:'auto'
	      	">
			<label class="textbox-label textbox-label-left" for="_easyui_textbox_input2" style="text-align: left;width:60px; height: 26px; line-height: 26px;">类型:</label>
		    <input id="weidengTodayRegistrationType" class="easyui-combobox" name="" style="width:150px;" data-options=" 
			      url:'', 
			      method:'get', 
			      valueField:'id', 
			      textField:'value', 
			      panelheight:'auto',
			      data: [{
						id: '1',
						value: '初诊'
					},{
						id: '2',
						value: '复诊'
					}]
	      	">
			<label class="textbox-label textbox-label-left" for="_easyui_textbox_input2" style="text-align: left;width:60px; height: 26px; line-height: 26px;">科室:</label>
		    <input id="weidengTodayRegistrationSection" class="easyui-combobox" name="" style="width:150px;" data-options=" 
			      url:'section/selectAll', 
			      method:'get', 
			      valueField:'id', 
			      textField:'name', 
			      panelheight:'auto'
	      	">
	      	
	    	<a id="btn" href="javaScript:void(0)" onclick="registrationSelectCondition()" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">serch</a>
	    	<a id="btn" href="javaScript:void(0)" onclick="addSeeDoctorRegister()" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">就诊登记</a>
	
		</div>
		<table class="easyui-datagrid" id="weidengRegistrationTable" 
				data-options="url:'registration/selectByTodayWeideng',method:'post',fitColumns:true,striped:true,rownumbers:true,singleSelect:true ">
			<thead>
				<tr>
					<th data-options="field:'id'" width="30">编号</th>
					<th data-options="field:'patient',formatter:patientFormatter" width="100">病人</th>
					<th data-options="field:'registrationChargeType',align:'right',formatter:registrationChargeTypeFormatter" width="100">挂号类型</th>
					<th data-options="field:'type',align:'right',formatter:registrationTypeFormatter" width="100">类型</th>
					<th data-options="field:'section',align:'right',formatter:sectionFormatter"  width="100">科室id</th>
					<th data-options="field:'user',align:'right',formatter:userFormatter" width="100">医生</th>
					<th data-options="field:'stage',align:'right',formatter:stageFormatter" width="100">上午/下午</th>
					<th data-options="field:'registrationMoney',align:'right'" width="100">金额</th>
					<th data-options="field:'registerState',align:'right',formatter:registerStateFormatter" width="100">登记状态</th>
				</tr>
			</thead>
		</table>
    </section>
    <section id="tab2" title="已登记病人">
		<div id="yidengTb">
			<label class="textbox-label textbox-label-left" for="_easyui_textbox_input2" style="text-align: left;width:130px; height: 26px; line-height: 26px;">姓名/标识/身份证:</label>
		 	<input class="easyui-textbox" id="yidengPatientName" name="patient.name"  style="width:150px;">
			<label class="textbox-label textbox-label-left" for="_easyui_textbox_input2" style="text-align: left;width:60px; height: 26px; line-height: 26px;">挂号类型:</label>
		    <input id="yidengTodayRegistrationRankClassType" class="easyui-combobox" name="" style="width:150px;" data-options=" 
			      url:'registrationChargeType/selectAll', 
			      method:'get', 
			      valueField:'id', 
			      textField:'typeName', 
			      panelheight:'auto'
	      	">
			<label class="textbox-label textbox-label-left" for="_easyui_textbox_input2" style="text-align: left;width:60px; height: 26px; line-height: 26px;">类型:</label>
		    <input id="yidengTodayRegistrationType" class="easyui-combobox" name="" style="width:150px;" data-options=" 
			      url:'', 
			      method:'get', 
			      valueField:'id', 
			      textField:'value', 
			      panelheight:'auto',
			      data: [{
						id: '1',
						value: '初诊'
					},{
						id: '2',
						value: '复诊'
					}]
	      	">
			<label class="textbox-label textbox-label-left" for="_easyui_textbox_input2" style="text-align: left;width:60px; height: 26px; line-height: 26px;">科室:</label>
		    <input id="yidengTodayRegistrationSection" class="easyui-combobox" name="" style="width:150px;" data-options=" 
			      url:'section/selectAll', 
			      method:'get', 
			      valueField:'id', 
			      textField:'name', 
			      panelheight:'auto'
	      	">
	      	
	    	<a id="btn" href="javaScript:void(0)" onclick="seeDoctorRegisterCondition()" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">serch</a>
	    	<a id="btn" href="javaScript:void(0)" onclick="addSeeDoctorRegister()" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">就诊登记</a>
	
		</div>
		<table class="easyui-datagrid" id="yidengRegistrationTable" 
				data-options="url:'seeDoctorRegister/selectList',method:'post',fitColumns:true,striped:true,rownumbers:true,singleSelect:true ">
			<thead>
				<tr>
					<th data-options="field:'id'" width="30">编号</th>
					<th data-options="field:'patient',formatter:yidengPatientFormatter" width="100">病人</th>
					<th data-options="field:'registrationChargeType',align:'right',formatter:yidengRegistrationChargeTypeFormatter" width="100">挂号类型</th>
					<th data-options="field:'type',align:'right',formatter:yidengRegistrationTypeFormatter" width="100">类型</th>
					<th data-options="field:'section',align:'right',formatter:yidengSectionFormatter"  width="100">科室id</th>
					<th data-options="field:'user',align:'right',formatter:yidengUserFormatter" width="100">医生</th>
					<th data-options="field:'stage',align:'right',formatter:yidengStageFormatter" width="100">上午/下午</th>
					<th data-options="field:'registerDate',align:'right'" width="100">登记时间</th>
					<th data-options="field:'comment',align:'right'" width="100">备注</th>
					<th data-options="field:'SeedoctorState',align:'right',formatter:yidengSeedoctorState" width="100">状态</th>
				</tr>
			</thead>
		</table>
    </section>
</div>


</body>

<script src="js/tabs/prefixfree.min.js"></script>
<script type="text/javascript" src="js/tabs/jquery-tab.js"></script>
<script type="text/javascript" src="js/registrationSelect.js"></script>
<script type="text/javascript">

	function yidengPatientFormatter (value,row,index){
		if(row.patient!=null){
			return row.patient.name;
		}
	}
	function yidengRegistrationChargeTypeFormatter (value,row,index){
		if(row.registration!=null){
			return row.registration.registrationChargeType.typeName;
		}
	}
	function yidengRegistrationTypeFormatter (value,row,index){
		if(row.registration!=null){
			if(row.registration.type==1){
				return "初诊";
			}
			if(row.registration.type==2){
				return "复诊";
			}
		}
	}
	function yidengSectionFormatter (value,row,index){
		if(row.registration.section!=null){
			return row.registration.section.name;
		}
	}
	function yidengUserFormatter (value,row,index){
		if(row.registration.user!=null){
			return row.registration.user.name;
		}
	}
	function yidengStageFormatter (value,row,index){
		if(row.registration.stage==0){
			return "上午";
		}
		if(row.registration.stage==1){
			return "下午";
		}
	}
	function yidengSeedoctorState (value,row,index){
		if(row.seeDoctorState==0){
			return "待诊";
		}
		if(row.seeDoctorState==1){
			return "接诊中";
		}
		if(row.seeDoctorState==2){
			return "完成就诊";
		}
		
	}

	$(function(){
		//tabs
		$('.tab-group').tabify();
		
		$("#weidengRegistrationTable").datagrid({
			pagination:true,
			toolbar:'#weidengTb',
			idField:"id"
		})
		$("#yidengRegistrationTable").datagrid({
			pagination:true,
			toolbar:'#yidengTb',
			idField:"id"
		})
	})
	function seeDoctorRegisterCondition(){
		$("#yidengRegistrationTable").datagrid("reload");
	}
	function registrationSelectCondition(){
		var postData = {};
		postData["patient.name"]=$("#weidengPatientName").val();
		postData["registrationChargeType.id"]=$("#weidengTodayRegistrationRankClassType").val();
		postData["type"]=$("#weidengTodayRegistrationType").val();
		postData["section.id"]=$("#weidengTodayRegistrationSection").val();
		postData["patient.name"]=$("#weidengPatientName").val();
		$("#weidengRegistrationTable").datagrid("reload",postData);
	}
	function addSeeDoctorRegister(){
		var row = $("#weidengRegistrationTable").datagrid("getSelected");
		if(row ==null ){
			$.messager.alert("提示","请选择要修改的数据行！","warning");
			return;
		}
		$("#weidengRegistrationTable").datagrid("clearSelections");
		$("#weidengRegistrationTable").datagrid("selectRecord",row.id);
		var d = $("<div></div>").appendTo("body");
		d.dialog({
			title:"就诊登记",
			iconCls:"icon-edit",
			width:400,
			height:380,
			modal:true,
			href:"seeDoctorRegister/seeDoctorRegisterForm",
			onClose:function(){$(this).dialog("destroy");},
			onLoad:function(){
				$.post("registration/selectById",{id:row.id},function(data){
					$("#seeDoctorRegisterForm").form("load",data);
					console.log(data);
					$("#bingrenxingming").textbox("setValue",data.patient.name);
					$("#keshiname").textbox("setValue",data.section.name);
					$("#yishengname").textbox("setValue",data.user.name);
					$("#guahaobianhao").val(data.id);
					if(data.type==1){
						$("#jiuzhenleixing").textbox("setValue","初诊");
					}else if(data.type==2){
						$("#jiuzhenleixing").textbox("setValue","复诊");						
					}
				})
			},
			buttons:[{
				iconCls:"icon-ok",
				text:"确定",
				handler:function(){
					$("#seeDoctorRegisterForm").form("submit",{
						url:"seeDoctorRegister/add",
						success:function(data){
							
							d.dialog("close");
							var result = (eval('(' + data + ')')).result;
							$.messager.alert("提示",result,"warning");
							$("#weidengRegistrationTable").datagrid("reload");
							
						}
					});
				}
			},{
				iconCls:"icon-cancel",
				text:"取消",
				handler:function(){
					d.dialog("close");
				}
			}]
		})
		
		
	}
</script>
</html>